package com.aspose.cells.a.d;

import com.aspose.cells.Color;
import com.aspose.cells.zazg;
import java.util.Stack;

public class zcn extends zck {
   private zn e;
   private zo f;
   private boolean g = false;
   public Stack b = new Stack();
   public zb c = new zb();
   private zb h = new zb();
   public com.aspose.cells.b.a.b.zq d = new com.aspose.cells.b.a.b.zq();

   public zcn(zcb var1) {
      super(var1);
      this.a = true;
   }

   public void a(com.aspose.cells.b.a.b.zo var1, com.aspose.cells.b.a.b.zt var2) throws Exception {
      this.b(var1, var2);
   }

   public void a(com.aspose.cells.b.a.b.zo var1, String var2) throws Exception {
      this.c(var1, var2);
   }

   public void b(com.aspose.cells.b.a.b.zo var1, String var2) throws Exception {
      this.c(var1, var2);
   }

   private void c(com.aspose.cells.b.a.b.zo var1, String var2) throws Exception {
      this.d(var1, var2);
      if ((this.a().j() & 1) == 1) {
         this.b((com.aspose.cells.b.a.b.zo)var1);
      }

   }

   public void a(com.aspose.cells.b.a.b.zo var1, Color var2) throws Exception {
      zn var3 = zn.a(var1, var1);
      var3.a = new zs(var2);
      this.a(var3, false, false);
   }

   public void a(com.aspose.cells.b.a.b.zo var1) throws Exception {
      if (this.g) {
         this.o();
         com.aspose.cells.b.a.b.zo[] var2 = new com.aspose.cells.b.a.b.zo[]{this.c(), var1};
         this.f.c(var2);
      } else {
         zn var3 = zn.a(this.c(), var1);
         this.a(var3, true, false);
      }

   }

   public void a(com.aspose.cells.b.a.b.zq var1) throws Exception {
      zn var2 = zn.b(var1);
      this.a(var2, true, true);
   }

   public void b(com.aspose.cells.b.a.b.zq var1) throws Exception {
      zn var2 = zn.b(var1);
      this.a(var2, false, true);
   }

   public void a(com.aspose.cells.b.a.b.zq var1, com.aspose.cells.b.a.b.zc var2) throws Exception {
      zn var3 = zn.b(var1);
      var3.a(var2);
      if (var3.d() != null) {
         var3.b(a(this.a().k()));
         var3.a(this.a().p());
         this.c.a((zl)var3);
      }
   }

   public void a(com.aspose.cells.b.a.b.zo[] var1) throws Exception {
      if (this.g) {
         this.o();
         this.f.c(var1);
      } else {
         zn var2 = zcg.a(var1, false);
         this.a(var2, true, false);
      }

   }

   public void c(com.aspose.cells.b.a.b.zo[] var1) throws Exception {
      if (this.g) {
         if (var1.length > 0) {
            this.b((com.aspose.cells.b.a.b.zo)var1[0]);
         }

         this.o();
         this.f.b(var1);
      } else {
         zn var2 = zcg.a(var1);
         this.a(var2, true, false);
         this.e = var2;
      }

   }

   public void b(com.aspose.cells.b.a.b.zo[][] var1) throws Exception {
      if (this.g) {
         this.o();

         for(int var2 = 0; var2 < var1.length; ++var2) {
            this.f.c(var1[var2]);
         }
      } else {
         zn var3 = zcg.a(var1, false);
         this.a(var3, true, false);
         this.e = var3;
      }

   }

   public void b(com.aspose.cells.b.a.b.zo[] var1) throws Exception {
      if (this.g) {
         this.o();
         this.f.a(var1[0]);
         this.f.c(var1);
      } else {
         zn var2 = zcg.a(var1, true);
         this.a(var2, true, true);
         this.e = var2;
      }

   }

   public void a(com.aspose.cells.b.a.b.zo[][] var1) throws Exception {
      zn var2 = zcg.a(var1, true);
      this.a(var2, false, true);
      this.e = var2;
   }

   public void a(com.aspose.cells.b.a.b.zq var1, com.aspose.cells.b.a.b.zo var2, com.aspose.cells.b.a.b.zo var3) throws Exception {
      zn var4 = zcg.a(var1, var2, var3);
      this.a(var4, true, false);
      this.e = var4;
   }

   public void c(com.aspose.cells.b.a.b.zq var1) throws Exception {
      zn var2 = zcg.a(var1);
      this.a(var2, true, true);
      this.e = var2;
   }

   public void b(com.aspose.cells.b.a.b.zq var1, com.aspose.cells.b.a.b.zo var2, com.aspose.cells.b.a.b.zo var3) throws Exception {
      zn var4 = zcg.b(var1, var2, var3);
      this.a(var4, true, true);
      this.e = var4;
   }

   public void c(com.aspose.cells.b.a.b.zq var1, com.aspose.cells.b.a.b.zo var2, com.aspose.cells.b.a.b.zo var3) throws Exception {
      zn var4 = zcg.c(var1, var2, var3);
      this.a(var4, true, true);
   }

   public void a(com.aspose.cells.b.a.b.zq var1, com.aspose.cells.b.a.b.zt var2) throws Exception {
      zn var3 = zcg.a(var1, var2);
      this.a(var3, true, true);
   }

   public void a(com.aspose.cells.b.a.b.zq var1, com.aspose.cells.b.a.b.zq var2, byte[] var3) {
      zb var4 = new zb();
      com.aspose.cells.b.a.b.zo var5 = new com.aspose.cells.b.a.b.zo(var2.j(), var2.k());
      com.aspose.cells.b.a.b.zt var6 = new com.aspose.cells.b.a.b.zt(var2.h(), var2.i());
      zj var7 = new zj(var5, var6, var3);
      var4.a((zl)var7);
      var4.a(this.a().p());
      this.c.a((zl)var4);
   }

   public void a(com.aspose.cells.b.a.b.zq var1, com.aspose.cells.b.a.b.zq var2, com.aspose.cells.b.a.b.a.zi var3, Color var4, long var5, byte[] var7) {
      zb var8 = new zb();
      com.aspose.cells.b.a.b.zo var9 = new com.aspose.cells.b.a.b.zo(var2.j(), var2.k());
      com.aspose.cells.b.a.b.zt var10 = new com.aspose.cells.b.a.b.zt(var2.h(), var2.i());
      zj var11 = new zj(var9, var10, var7);
      var11.a(var5);
      var8.a((zl)var11);
      var8.a(this.a().p());
      var8.a().b(var3);
      this.c.a((zl)var8);
   }

   public void d(com.aspose.cells.b.a.b.zq var1) {
      zn var2 = new zn(var1);
      zb var3 = new zb();
      var3.a(var2);
      this.c.a((zl)var3);
      this.c = var3;
   }

   private void a(zn var1, boolean var2, boolean var3) throws Exception {
      if (var2) {
         var1.a = zs.a(this.a().c());
      }

      if (var3) {
         var1.a(this.a().d());
      }

      if (var1.a != null || var1.d() != null) {
         switch(this.a().m()) {
         case 9:
         default:
            var1.b(a(this.a().k()));
            var1.a(this.a().p());
            this.c.a((zl)var1);
            return;
         case 11:
         }
      }
   }

   public static int a(int var0) throws Exception {
      switch(var0) {
      case 1:
         return 0;
      case 2:
         return 1;
      default:
         throw new Exception(com.aspose.cells.b.a.zv.a("Unknown GDI fill mode[{0}].", var0));
      }
   }

   private void b(com.aspose.cells.b.a.b.zo var1, com.aspose.cells.b.a.b.zt var2) throws Exception {
      com.aspose.cells.b.a.b.zt var3 = this.b().i();
      float var4 = var2.b() / var3.b();
      float var5 = var2.c() / var3.c();
      if (var3.b() * var3.c() <= 0.0F || var2.b() * var2.c() <= 0.0F) {
         var4 = 1.0E-4F;
         var5 = 1.0E-4F;
      }

      this.h.a(new com.aspose.cells.b.a.b.a.zi(var4, 0.0F, 0.0F, var5, var1.d(), var1.e()));
      this.h.a().b(-this.b().j().d(), -this.b().j().e());
      this.h.a((zl)this.c);
   }

   private void d(com.aspose.cells.b.a.b.zo var1, String var2) throws Exception {
      zav var3 = this.a().e();
      var2 = zazg.a(var2);
      if (!zfs.a(var3.a(), var3.c(), var2)) {
         var3 = new zav(zbw.a, var3.b(), var3.c());
      }

      zf var4 = new zf(var3, this.a().i(), var1, (float)this.a().l(), var2);
      if (var3.g()) {
         var4.c = 1;
      }

      zb var5 = new zb();
      var5.a(this.a().p());
      com.aspose.cells.b.a.b.zo[] var6 = new com.aspose.cells.b.a.b.zo[]{var1};
      var5.a().b(this.a().a(var6, var4.i(), var4.d()));
      var1 = var6[0];
      var5.a().a(this.a().q(), this.a().r());
      var3 = new zav(var3.a(), var3.b() / Math.abs(this.a().r()), var3.c());
      var4.a(new com.aspose.cells.b.a.b.zo(var1.d() / this.a().q(), var1.e() / this.a().r()));
      if (this.a().s() != null) {
         float var7 = var1.d();

         for(int var8 = 0; var8 < var2.length(); ++var8) {
            com.aspose.cells.b.a.b.zo var9 = new com.aspose.cells.b.a.b.zo(var7 / this.a().q(), var1.e() / this.a().r());
            zf var10 = new zf(var3, this.a().i(), var9, (float)this.a().l(), Character.toString(var2.charAt(var8)));
            if (var3.g()) {
               var10.c = 1;
            }

            var5.a((zl)var10);
            var7 += (float)(this.a().s()[var8] & 4294967295L);
         }
      } else {
         var4.a(var3);
         var5.a((zl)var4);
      }

      this.a(var4, var5);
      this.c.a((zl)var5);
   }

   private void a(zf var1, zb var2) throws Exception {
      com.aspose.cells.b.a.b.zq var3 = new com.aspose.cells.b.a.b.zq(var1.g(), var1.i());
      zn var4 = zn.b(var3);
      var4.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(this.a().g())));
      if (this.a().h() != 1 || (this.a().g().getR() & 255) != 255 || (this.a().g().getG() & 255) != 255 || (this.a().g().getB() & 255) != 255) {
         var4.a(var2.a().b());
         var4.a().b(0.0F, -var1.d().h());
         this.c.a((zl)var4);
      }
   }

   public zb e() {
      return this.h;
   }

   private void o() {
      if (this.f == null) {
         this.f = new zo(this.c());
      }

   }

   public void f() throws Exception {
      this.a(true);
   }

   public void g() {
      this.g = true;
      this.e = new zn();
      this.f = null;
   }

   public void h() throws Exception {
      this.a(false);
      this.i();
      this.g = false;
   }

   public void i() {
      if (this.g && this.e.a() == null) {
         this.e.a(this.a().p().b());
      }

   }

   private void a(boolean var1) throws Exception {
      if (this.f != null) {
         this.f.a(var1);
         this.e.b(a(this.a().k()));
         this.e.a((zl)this.f);
         this.f = null;
      }
   }

   public void j() throws Exception {
      if (this.e != null && this.a().d() != null) {
         this.a(true);
         this.e.a(this.a().d());
         this.p();
      }
   }

   public void k() throws Exception {
      if (this.e != null && this.a().c() != null) {
         this.a(false);
         this.e.a = zs.a(this.a().c());
         this.p();
      }
   }

   public void l() throws Exception {
      if (this.e != null && (this.a().d() != null || this.a().c() != null)) {
         this.a(false);
         this.e.a(this.a().d());
         this.e.a = null;
         this.p();
      }
   }

   public void m() {
      zb var1 = new zb();
      this.c.a((zl)var1);
      this.b.push(this.c);
      this.c = var1;
      this.e = null;
      this.f = null;
   }

   public void n() {
      this.c = (zb)this.b.pop();
      this.e = null;
      this.f = null;
   }

   private void p() throws Exception {
      this.e.b(a(this.a().k()));
      this.c.a((zl)this.e);
      this.e = null;
   }

   public void b(int var1) throws Exception {
      this.a(true);
      zb var2 = new zb();
      switch(var1) {
      case 1:
         var2.a(this.e);
         this.c.a((zl)var2);
         this.c.g().remove(this.e);
         this.c = var2;
         this.e = null;
         break;
      case 5:
         if (this.c.o() != null) {
            this.c.o().a((zl)var2);
            this.c = var2;
            this.c.a(this.e);
         }

         this.e = null;
         break;
      default:
         var2.a(this.e);
         this.h.a((zl)var2);
         this.c = var2;
         this.e = null;
      }

   }
}
